package com.zycfc.zsf.boot.util.h2;

import java.sql.*;
import com.zycfc.zsf.boot.util.time.*;

public class H2Function
{
    public static String dateFormat(final Date date, String format) {
        final String s = format;
        switch (s) {
            case "%Y": {
                format = "yyyy";
                break;
            }
            case "%Y-%m": {
                format = "yyyy-MM";
                break;
            }
            case "%Y-%m-%d": {
                format = "yyyy-MM-dd";
                break;
            }
            case "%Y-%m-%d %H": {
                format = "yyyy-MM-dd HH";
                break;
            }
            case "%Y-%m-%d %H:%i": {
                format = "yyyy-MM-dd HH:mm";
                break;
            }
            case "%Y-%m-%d %H:%i:%s": {
                format = "yyyy-MM-dd HH:mm:ss";
                break;
            }
            default: {
                format = "yyyy-MM-dd HH:mm:ss";
                break;
            }
        }
        return DateUtils.dateToString(date, format);
    }
}
